import React, { Component } from 'react';

class Refone extends Component {
    getData=()=>{
        console.log(this.refs.username.value);
    }
    render() {
        return (
            <>
                <h1>字符串形式的[ref]:获取真实dom对象</h1>
                <input ref='username' type='text'/>
                <button ref="btn" onClick={this.getData}>获取数据</button>
            </>
        );
    }
}

export default Refone;